import { isArray } from '@guanwei/app-javascript'
import ProIcon from './icon.vue'

export default function(_Vue, options) {
  if (options && isArray(options.imports)) {
    options.imports.forEach(name => {
      require(`@/assets/svg/${ name }.svg`)
    })
  } else {
    const context = require.context('@/assets/svg', false, /\.svg$/)
    context.keys().forEach(path => {
      const temp = path.match(/\.\/([A-Za-z0-9\-_]+)\.svg$/)
      if (!temp) return
      const name = temp[1]
      require(`@/assets/svg/${ name }.svg`)
    })
  }
  _Vue.component(ProIcon.name, ProIcon)
}
